from rest_framework import serializers

from .models import User

class UserInfoSerializer(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = ['id', 'username', 'nickname', 'gender', 'email', 'birthday', 'id_card','mobile_num', 'avatar', 'date_joined', 'last_login'] # 序列化的字段

class UserUpdateSerializer(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = ['nickname', 'gender', 'email'] # 允许更新的字段
        read_only_fields = ['id', 'username', 'password', 'date_joined', 'last_login', 'is_active', 'is_staff', 'is_superuser'] # 禁止更新的字段